#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include "osdep.h"
#include "airkiss.h"

#define BUF_SIZE	1024
#define SLEEP_INTERVAL	1000	/* 1ms */
#define DEFAULT_CHANNEL 1


int main(int argc, const char *argv[])
{
	struct wif *wi;
	char *iface;
	char buf[BUF_SIZE];
	int i;
	int ret;
	int chan = 1;
	struct airkiss_context ac;

	if (argc != 2) {
		printf("Usage: %s <iface>\n", argv[0]);
		return 1;
	}

	iface = argv[1];

	wi = wi_open(iface);
	if (!wi) {
		printf("cannot init interface %s\n", iface);
		return 1;
	}

	ret = wi->wi_set_channel(wi, DEFAULT_CHANNEL);
	if (ret) {
		printf("cannot set channel to %d\n", DEFAULT_CHANNEL);
		return 1;
	}

	for (i = 0; i < BUF_SIZE; i++)
		buf[i] = i;

	memset(&ac, 0, sizeof(ac));

	while (1) {
		ret = wi->wi_read(wi, buf, BUF_SIZE, NULL);
		if (ret < 0) {
			printf("recv failed, ret %d\n", ret);
			break;
		}
		airkiss_recv(&ac, buf, ret);
	}
	return 0;
}
